<?php
$printTemplateArray = $this->adminHelper()->erpPrintTemplateState('stockCheck');
if ($printTemplateArray['state']) echo $this->partial('admin/print-template/inCss');
?>
<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('stock-check');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回盘点列表'); ?></a>
            <button type="button" onclick="<?php echo $printTemplateArray['state'] ? 'directPrint()' : 'toPrint()'; ?>;" class="btn btn-primary btn-sm"><i class="fa fa-print" aria-hidden="true"></i> <?php echo $this->translate('点击打印'); ?></button>
            <?php echo $this->HelpUrl('stockCheck'); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12" id="to-print-info">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo $this->translate('库存盘点详情'); ?></h3>
                    </div>

                    <div class="box-body">
                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('盘点单号'); ?>：</b><?php echo $this->escapeHtml($this->stockCheckInfo->getStockCheckSn());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('仓库'); ?>：</b><?php echo $this->escapeHtml($this->stockCheckInfo->getOneWarehouse()->getWarehouseName());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('状态'); ?>：</b><?php echo $this->stockCheckInfo->getStockCheckState() == 1 ? $this->translate('已盘点') : $this->translate('待盘点');?>
                                </div>
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('盘点时间'); ?>：</b><?php echo date("Y-m-d", $this->stockCheckInfo->getStockCheckTime());?>
                                </div>
                            </div>
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('盘点人'); ?>：</b><?php echo $this->escapeHtml($this->stockCheckInfo->getStockCheckUser());?>
                                </div>
                            </div>
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('盘点备注'); ?>：</b><?php echo $this->escapeHtml($this->stockCheckInfo->getStockCheckInfo());?>
                                </div>
                            </div>
                        </div>

                        <div class="box-header">
                            <h4 class="box-title"><?php echo $this->translate('盘点商品'); ?></h4>
                        </div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th width="15%"><?php echo $this->translate('商品编号'); ?></th>
                                    <th width="20%"><?php echo $this->translate('商品名称'); ?></th>
                                    <th width="15%"><?php echo $this->translate('商品规格'); ?></th>
                                    <th width="5%"><?php echo $this->translate('单位'); ?></th>
                                    <th width="8%"><?php echo $this->translate('盘点前库存'); ?></th>
                                    <th width="10%"><?php echo $this->translate('盘点后库存'); ?></th>
                                    <th width="10%"><?php echo $this->translate('盘点后金额'); ?></th>
                                </tr>
                                </thead>
                                <?php foreach ($this->stockCheckGoods as $goodsValue) { ?>
                                    <tr>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsNumber()); ?></td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsName()); ?></td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsSpec()); ?></td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsUnit()); ?></td>
                                        <td><?php echo $goodsValue->getStockCheckPreGoodsNum(); ?></td>
                                        <td><?php echo $goodsValue->getStockCheckAftGoodsNum(); ?></td>
                                        <td><?php echo $this->erpCurrencyFormat($goodsValue->getStockCheckGoodsAmount()); ?></td>
                                    </tr>
                                <?php } ?>

                                <tfoot>
                                <tr>
                                    <td colspan="5"></td>
                                    <td colspan="2" class="text-right"><b><?php echo $this->translate('金额合计'); ?>：</b><span id="order-amount"><?php echo (isset($this->stockCheckInfo) ? $this->erpCurrencyFormat($this->stockCheckInfo->getStockCheckAmount()) : 0); ?></span></td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>

                    </div>

                </div>


            </div>
        </div>

    </section>

</div>
<?php
if ($printTemplateArray['state']) {
    echo $this->partial('admin/print-template/inJavascript', [
        'templateBody' => $printTemplateArray['templateBody'],
        'templateCode' => $printTemplateArray['templateCode'],
        'printData' => \Admin\Service\Common\PrintTemplate::stockCheck([
            'stockCheckInfo'   => $this->stockCheckInfo,
            'stockCheckGoods'  => $this->stockCheckGoods
        ], $printTemplateArray['templateBody'])]);
}
?>